import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "vue-router";
import { routeData } from "./index";

export const routes = routeData;
const router = createRouter({
  scrollBehavior: () => ({ left: 0, top: 0 }),
  history: createWebHashHistory(),
  routes,
});
router.beforeEach((to, from, next) => {
  next();
});
//导航后置守卫
router.afterEach((to, from, next) => {
  let name = "";
  if (to.name) {
    name = String(to.name);
  }
  document.title = name || "xxx系统";
});
export default router;
